home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / rw_hashset.z / rw_hashset
Encoding:
Text File  |  1998-10-30  |  18.8 KB  |  463 lines

  1.  
  2.  
  3.  
  4. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      rw_hashset - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/rwstl/hashset.h>
  13.           rw_hashset<T,Hash,EQ> set;
  14.  
  15.  
  16.  
  17.  
  18. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  19.      Class rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> maintains a collection of TTTT, implemented as a
  20.      hash table in which there may not be more than one instance of any given
  21.      TTTT. Since this is a vvvvaaaalllluuuueeee based collection, objects are ccccooooppppiiiieeeedddd into and
  22.      out of the collection.  As with all classes that meet the ANSI
  23.      aaaassssssssoooocccciiiiaaaattttiiiivvvveeee ccccoooonnnnttttaaaaiiiinnnneeeerrrr specification, rrrrwwww____hhhhaaaasssshhhhsssseeeetttt provides for iterators
  24.      that reference its elements.  Operations that alter the contents of
  25.      rrrrwwww____hhhhaaaasssshhhhsssseeeetttt may invalidate other iterators that reference the container.
  26.      Since the contents of rrrrwwww____hhhhaaaasssshhhhsssseeeetttt are in pseudo-random order, the only
  27.      iterator ranges that will usually make sense are the results of calling
  28.      eeeeqqqquuuuaaaallll____rrrraaaannnnggggeeee((((kkkkeeeeyyyy)))), and the entire range from bbbbeeeeggggiiiinnnn(((()))) to eeeennnndddd(((()))).
  29.  
  30. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  31.      None
  32.  
  33. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss
  34.               typedef T                   key_type;
  35.           typedef T                   value_type; // or ... "const K"
  36.           typedef Hash                key_hash;
  37.           typedef EQ                  key_equal;
  38.           typedef (unsigned)          size_type; //from rw_slist
  39.           typedef (int)               difference_type; // from rw_slist
  40.           typedef (value_type&)       reference;
  41.           typedef (const value_type&) const_reference; //from rw_slist
  42.  
  43.  
  44.      Iterators over rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> are forward iterators.
  45.  
  46.               typedef (scoped Iterator)     iterator;
  47.           typedef (scoped ConsIterator) const_iterator;
  48.  
  49.  
  50.  
  51. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  52.               rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>>(size_type sz = 1024,
  53.                                 const Hash& h = Hash(),
  54.                                 const EQ& eq = EQ());
  55.  
  56.  
  57.      Construct an empty rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> with sssszzzz slots, using hhhh as the
  58.      hash object, and eeeeqqqq as the equality comparator.
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>>(const rw_hashset<T,Hash,EQ>& set);
  75.  
  76.  
  77.      Construct an rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> which is a copy of sssseeeetttt.  Each element
  78.      from sssseeeetttt will be copied into self.
  79.  
  80.               rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>>(const_iterator first,
  81.                                 const_iterator bound
  82.                                 size_type sz=1024,
  83.                                 const Hash& h = Hash(),
  84.                                 const EQ& eq = EQ());
  85.  
  86.  
  87.      Construct an rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> with sssszzzz slots, using hhhh as the hash
  88.      object, and eeeeqqqq as the equality comparator, containing a copy of each item
  89.      referenced by the range starting with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd.
  90.  
  91.               rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>>(const value_type* first,
  92.                                 const value_type* bound
  93.                                 size_type sz=1024,
  94.                                 const Hash& h = Hash(),
  95.                                 const EQ& eq = EQ());
  96.  
  97.  
  98.      Construct an rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>> with sssszzzz slots, using hhhh as the hash
  99.      object, and eeeeqqqq as the equality comparator, containing a copy of each item
  100.      referenced by the range starting with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd.  If
  101.      there are items in the range which test EEEEQQQQ, then only the first such item
  102.      will be inserted into self.
  103.  
  104. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  105.               ~~~~rrrrwwww____hhhhaaaasssshhhhsssseeeetttt<<<<TTTT,,,,HHHHaaaasssshhhh,,,,EEEEQQQQ>>>>();
  106.  
  107.  
  108.      The destructor releases the memory used by the container's
  109.      implementation.
  110.  
  111. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  112.               rw_hashset<T,Hash,EQ>&
  113.           ooooppppeeeerrrraaaattttoooorrrr====(const rw_hashset<T,Hash,EQ>& rhs);
  114.  
  115.  
  116.      Sets self to have the same capacity, HHHHaaaasssshhhh and EEEEQQQQ as rrrrhhhhssss, removes all
  117.      self's current contents, and replaces them with copies of the elements in
  118.      rrrrhhhhssss.
  119.  
  120.               bool
  121.           ooooppppeeeerrrraaaattttoooorrrr========(const rw_hashset<T,Hash,EQ> & rhs) const;
  122.  
  123.  
  124.      Returns true if self and rrrrhhhhssss have the same number of elements, and for
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      each item in self there is an item in rrrrhhhhssss which tests EEEEQQQQ.
  141.  
  142. AAAAcccccccceeeessssssssoooorrrrssss
  143.               iterator
  144.           bbbbeeeeggggiiiinnnn();
  145.  
  146.  
  147.      The iterator returned references the first item in self.  If self is
  148.      empty, the iterator is equal to eeeennnndddd(((()))).  Note that because items are
  149.      stored in pseudo-random order, this iterator might reference any item
  150.      that has been stored in self.
  151.  
  152.               const_iterator
  153.           bbbbeeeeggggiiiinnnn() const;
  154.  
  155.  
  156.      The iterator returned references the first item in self.  If self is
  157.      empty, the iterator is equal to eeeennnndddd(((()))).  Note that because items are
  158.      stored in pseudo-random order, this iterator might reference any item
  159.      that has been stored in self.
  160.  
  161.               iterator
  162.           eeeennnndddd();
  163.  
  164.  
  165.      The iterator returned marks the location "off the end" of self.  It may
  166.      not be dereferenced.
  167.  
  168.               const_iterator
  169.           eeeennnndddd() const;
  170.  
  171.  
  172.      The iterator returned marks the location "off the end" of self.  It may
  173.      not be dereferenced.
  174.  
  175.               pair<const_iterator, const_iterator>
  176.           eeeeqqqquuuuaaaallll____rrrraaaannnnggggeeee(const key_type key) const;
  177.  
  178.  
  179.      Returns ppppaaaaiiiirrrr<<<<ccccoooonnnnsssstttt____iiiitttteeeerrrraaaattttoooorrrr,,,, ccccoooonnnnsssstttt____iiiitttteeeerrrraaaattttoooorrrr>>>>((((lllloooowwwweeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))),,,,
  180.      uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))))))).  Upper and lower bound have special meaning for hash-
  181.      based collections.  See discussion elsewhere.
  182.  
  183.               pair<iterator, iterator>
  184.           eeeeqqqquuuuaaaallll____rrrraaaannnnggggeeee(const key_type key);
  185.  
  186.  
  187.      Returns ppppaaaaiiiirrrr<<<<iiiitttteeeerrrraaaattttoooorrrr,,,,iiiitttteeeerrrraaaattttoooorrrr>>>>((((lllloooowwwweeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))),,,, uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd((((kkkkeeeeyyyy)))))))).
  188.      Upper and lower bound have special meaning for hash-based collections.
  189.      See discussion elsewhere.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               onst_iterator
  207.           lllloooowwwweeeerrrr____bbbboooouuuunnnndddd(const key_type& key) const;
  208.  
  209.  
  210.      Returns the lower bound of kkkkeeeeyyyy in self.  This has a special meaning for
  211.      hash-based collections.  See discussion elsewhere.
  212.  
  213.               iterator
  214.           lllloooowwwweeeerrrr____bbbboooouuuunnnndddd(const key_type& key);
  215.  
  216.  
  217.      Returns the lower bound of kkkkeeeeyyyy in self.  This has a special meaning for
  218.      hash-based collections.  See discussion elsewhere.
  219.  
  220.               const_iterator
  221.           uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd(const key_type& key) const;
  222.  
  223.  
  224.      Returns the upper bound of kkkkeeeeyyyy in self.  This has a special meaning for
  225.      hash-based collections.  See discussion elsewhere.
  226.  
  227.               iterator
  228.           uuuuppppppppeeeerrrr____bbbboooouuuunnnndddd(const key_type& key);
  229.  
  230.  
  231.      Returns the upper bound of kkkkeeeeyyyy in self.  This has a special meaning for
  232.      hash-based collections.  See discussion elsewhere.
  233.  
  234. CCCCoooonnnnsssstttt PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  235.               size_type
  236.           ccccaaaappppaaaacccciiiittttyyyy() const;
  237.  
  238.  
  239.      Returns the number of slots in the hash table that self uses.
  240.  
  241.               bool
  242.           eeeemmmmppppttttyyyy() const;
  243.  
  244.  
  245.      Returns ttttrrrruuuueeee if self is empty.
  246.  
  247.               float
  248.           ffffiiiillllllll____rrrraaaattttiiiioooo() const;
  249.  
  250.  
  251.      Returns the result of calculating ssssiiiizzzzeeee(((())))////ccccaaaappppaaaacccciiiittttyyyy(((()))).
  252.  
  253.               size_type
  254.           ssssiiiizzzzeeee() const;
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      Returns the number of items currently held in self.
  273.  
  274. MMMMuuuuttttaaaattttoooorrrrssss
  275.               void
  276.           cccclllleeeeaaaarrrr();
  277.  
  278.  
  279.      A synonym for eeeerrrraaaasssseeee((((bbbbeeeeggggiiiinnnn(((()))),,,,eeeennnndddd(((())))))));;;;
  280.  
  281.               size_type
  282.           eeeerrrraaaasssseeee(const key_type& key);
  283.  
  284.  
  285.      If there is an item EEEEQQQQ to kkkkeeeeyyyy, it is removed, and 1111 is returned.
  286.      Otherwise, 0000 is returned.
  287.  
  288.               iterator
  289.           eeeerrrraaaasssseeee(iterator iter);
  290.  
  291.  
  292.      Removes the element referenced by iiiitttteeeerrrr and returns an iterator
  293.      referencing the "next" element.  If iiiitttteeeerrrr does not reference an item in
  294.      self, the result is undefined.
  295.  
  296.               iterator
  297.           eeeerrrraaaasssseeee(iterator first, iterator bound);
  298.  
  299.  
  300.      Removes each element in the range which begins with ffffiiiirrrrsssstttt and is bounded
  301.      by bbbboooouuuunnnndddd.  Returns an iterator referencing bbbboooouuuunnnndddd.  If ffffiiiirrrrsssstttt does not
  302.      reference an item in self (and if ffffiiiirrrrsssstttt and bbbboooouuuunnnndddd are not equal), the
  303.      effect is undefined.
  304.  
  305.               pair<iterator,bool>
  306.           iiiinnnnsssseeeerrrrtttt(const value_type& val);
  307.  
  308.  
  309.      If there is no item in self EEEEQQQQ to vvvvaaaallll then inserts vvvvaaaallll, returning a pair
  310.      with an iterator referencing the new element and true.  Otherwise,
  311.      returns a pair with an iterator referencing the matching vvvvaaaalllluuuueeee____ttttyyyyppppeeee and
  312.      false.
  313.  
  314.               size_type
  315.           iiiinnnnsssseeeerrrrtttt(iterator ignore, const value_type& val);
  316.  
  317.  
  318.      If there is no item in self EEEEQQQQ to vvvvaaaallll then inserts vvvvaaaallll, returning 1111.
  319.      Otherwise, does nothing and returns 0000.  Note that the first argument is
  320.      provided only for conformance with the ANSI aaaassssssssoooocccciiiiaaaattttiiiivvvveeee ccccoooonnnnttttaaaaiiiinnnneeeerrrr
  321.      specification, and is ignored by the method, since hash table look up can
  322.      be done in constant time.
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.               size_type
  339.           iiiinnnnsssseeeerrrrtttt(const value_type* first, const value_type* bound);
  340.  
  341.  
  342.      For each element in the range beginning with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd,,,,
  343.      if there is no item in self EEEEQQQQ to that element, the element is copied
  344.      into self, or if there is such an element, it is skipped.  Returns the
  345.      number of elements inserted.
  346.  
  347.               size_type
  348.           iiiinnnnsssseeeerrrrtttt(const_iterator first, const_iterator bound);
  349.  
  350.  
  351.      For each element in the range beginning with ffffiiiirrrrsssstttt and bounded by bbbboooouuuunnnndddd,,,,
  352.      if there is no item in self EEEEQQQQ to that element, the element is copied
  353.      into self, or if there is such an element, it is skipped.  Returns the
  354.      number of elements inserted.
  355.  
  356.               void
  357.           sssswwwwaaaapppp(rw_hashset<T,Hash,EQ>& other);
  358.  
  359.  
  360.      Exchanges the contents of self with ooootttthhhheeeerrrr including the HHHHaaaasssshhhh and EEEEQQQQ
  361.      objects.  This method does not copy or destroy any of the items exchanged
  362.      but exchanges the underlying hash tables.
  363.  
  364. SSSSppppeeeecccciiiiaaaallll MMMMeeeetttthhhhooooddddssss ffffoooorrrr SSSSeeeettttssss
  365.               size_type
  366.           ccccoooouuuunnnntttt(const key_type& key) const;
  367.  
  368.  
  369.      Returns 1111 if self contains kkkkeeeeyyyy, else 0000.
  370.  
  371.               const_iterator
  372.           ffffiiiinnnndddd(const key_type& key) const;
  373.  
  374.  
  375.      Returns a const_iterator referencing kkkkeeeeyyyy, if it is contained in self,
  376.      else returns eeeennnndddd(((()))).
  377.  
  378.               iterator
  379.           ffffiiiinnnndddd(const key_type& key);
  380.  
  381.  
  382.      Returns an iterator referencing kkkkeeeeyyyy, if it is contained in self, else
  383.      returns eeeennnndddd(((()))).
  384.  
  385.               void
  386.           rrrreeeessssiiiizzzzeeee(size_type sz);
  387.  
  388.  
  389.      Resizes self's hash table to have sssszzzz slots; and re-hashes all self's
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))                                              rrrrwwww____hhhhaaaasssshhhhsssseeeetttt((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.      elements into the new table.  Can be very expensive if self holds many
  405.      elements.
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.